:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #4895ef;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --success-color: #4cc9f0;
    --warning-color: #f72585;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: var(--dark-color);
    line-height: 1.6;
}

.container {
    display: flex;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* 侧边栏样式 */
.sidebar {
    width: 300px;
    background-color: white;
    border-right: 1px solid #e1e4e8;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e1e4e8;
    text-align: center;
}

.sidebar-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid #e1e4e8;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: #6c757d;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.tab-content {
    display: none;
    padding: 15px 0;
}

.tab-content.active {
    display: block;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.list-item:hover {
    background-color: #f1f3f5;
}

.list-item.active {
    background-color: #e6f0ff;
    color: var(--primary-color);
}

.list-item .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    overflow: hidden;
}

.list-item .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.list-item .info {
    flex: 1;
}

.list-item .info h4 {
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.list-item .info p {
    font-size: 0.8rem;
    color: #6c757d;
}

.list-item .status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #adb5bd;
}

.list-item .status.online {
    background-color: var(--success-color);
}

/* 主聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    height: 700px;
    flex-direction: column;
    background-color: white;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #e1e4e8;
    display: flex;
    align-items: center;
}

.chat-header .room-info {
    flex: 1;
}

.chat-header .room-info h3 {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.chat-header .room-info p {
    font-size: 0.85rem;
    color: #6c757d;
}

.chat-header .actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: #6c757d;
    font-size: 1.1rem;
    margin-left: 15px;
    transition: var(--transition);
}

.chat-header .actions button:hover {
    color: var(--primary-color);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f8f9fa;
}

.message {
    display: flex;
    margin-bottom: 20px;
}

.message .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    overflow: hidden;
    flex-shrink: 0;
}

.message .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message .content {
    max-width: 70%;
}

.message .content .info {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.message .content .info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-right: 8px;
}

.message .content .info time {
    font-size: 0.75rem;
    color: #6c757d;
}

.message .content .text {
    background-color: white;
    padding: 12px 15px;
    border-radius: 0 var(--border-radius) var(--border-radius) var(--border-radius);
    box-shadow: var(--box-shadow);
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
}

.message .content .media {
    margin-top: 8px;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    max-width: 100%;
}

.message .content .media img {
    max-width: 100%;
    max-height: 300px;
    display: block;
    object-fit: contain;
}

.message .content .media video {
    max-width: 100%;
    max-height: 300px;
    display: block;
    background-color: #000;
}

.message.self {
    justify-content: flex-end;
}

.message.self .content {
    order: -1;
    margin-right: 12px;
}

.message.self .content .text {
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--border-radius) 0 var(--border-radius) var(--border-radius);
}

.message.self .content .info {
    justify-content: flex-end;
}

.chat-input {
    padding: 15px;
    border-top: 1px solid #e1e4e8;
    background-color: white;
    position: relative;
}

.input-group {
    display: flex;
    align-items: center;
}

.input-group .input-actions {
    display: flex;
    margin-right: 10px;
}

.input-group .input-actions button {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    transition: var(--transition);
}

.input-group .input-actions button:hover {
    color: var(--primary-color);
}

.input-group input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #e1e4e8;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.input-group button.send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 12px 20px;
    margin-left: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.input-group button.send-btn:hover {
    background-color: var(--secondary-color);
}

/* 文件上传按钮 */
.file-input {
    display: none;
}

/* 预览区域 */
.preview-container {
    display: none;
    padding: 10px;
    background-color: #f1f3f5;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    position: relative;
}

.preview-container.active {
    display: block;
}

.preview-item {
    position: relative;
    display: inline-block;
    margin-right: 10px;
    margin-bottom: 10px;
}

.preview-item img, .preview-item video {
    max-width: 150px;
    max-height: 150px;
    border-radius: var(--border-radius);
}

.preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
}

/* 新建房间模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e1e4e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--dark-color);
}

.modal-header .close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e1e4e8;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e1e4e8;
    display: flex;
    justify-content: flex-end;
    background-color: #f8f9fa;
}

.modal-footer button {
    padding: 10px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.modal-footer button.cancel {
    background-color: #f1f3f5;
    border: 1px solid #e1e4e8;
    color: #6c757d;
    margin-right: 10px;
}

.modal-footer button.cancel:hover {
    background-color: #e9ecef;
}

.modal-footer button.submit {
    background-color: var(--primary-color);
    border: none;
    color: white;
}

.modal-footer button.submit:hover {
    background-color: var(--secondary-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e1e4e8;
    }

    .chat-area {
        min-height: 70vh;
    }

    .message .content {
        max-width: 80%;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    animation: fadeIn 0.3s ease forwards;
}
